﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Strategy
{
    //四则运算

    public interface IOperation
    {
        float Call(float f1, float f2);
    }

    //运算操作类

    public class OpeationCall
    {
        public IOperation operation;
        public OpeationCall(IOperation oper)
        {
            this.operation = oper;
        }

        public float CallResult(float f1, float f2)
        {
            float f = float.NaN;

            if (operation!=null)
            {
                f = operation.Call(f1, f2);
            }
            return f;
        }
    }

    #region 运算实体方法
    public class AddOperation : IOperation
    {
        public float Call(float f1, float f2)
        {
            return f1 + f2;
        }
    }

    public class SubOperation : IOperation
    {
        public float Call(float f1, float f2)
        {
            return f1 - f2;
        }
    }

    public class MultikplyOPeration : IOperation
    {
        public float Call(float f1, float f2)
        {
            return f1 * f2;
        }
    }

    public class DivideOperation : IOperation
    {
        public float Call(float f1, float f2)
        {
            return f1 / f2;
        }
    }

    #endregion
}
